using System;
using System.Collections.Generic;
using System.Text;

namespace Pegasus
{
	/// <summary>
	/// Has additional string methods.
	/// </summary>
	public static class StringHelper
	{
		/// <summary>
		/// Centers the specified string.
		/// </summary>
		/// <param name="str">The string to center.</param>
		/// <param name="ch">The char to pad on eather side.</param>
		/// <param name="length">The length.</param>
		/// <returns></returns>
		public static string Center( string str, char ch, int length )
		{
			string result = str;

			int strLength = str.Length;
			if( strLength < length )
			{
				int diff = length - strLength;

				result = result.PadLeft( ( diff / 2 ) + strLength, ch );
				result = result.PadRight( diff + strLength, ch );
			}

			return result;
		}
	}
}
